import auctionhausen.Customer
import auctionhausen.Bid
import auctionhausen.Listing

class BootStrap {

	def init = { servletContext ->
		//create customers
		def c1 = new Customer(email:'mike@test.umn.edu', password:'123456')
		c1.save(flush:true)
		def c2 = new Customer(email:'ted@test.umn.edu', password:'jlsakj6')
		c2.save(flush:true)
		def c3 = new Customer(email:'alf@test.umn.edu', password:'jaasffd')
		c3.save(flush:true)
		def c4 = new Customer(email:'mitch@mitch.com', password:'123456')
		c4.save(flush:true)

		// create admins
		def a1 = new Customer(email:'mitch.sans.souci@gmail.com', password:'admin1', isAdmin:true)
		a1.save(flush:true)
		def a2 = new Customer(email:'joel@joel.com', password:'admin2', isAdmin:true)
		a2.save(flush:true)
		
		//create listings
		def l1 = new Listing(
			name:"Harry Potter Koozie", 
			endDate:(new Date()+1), 
			startingPrice:4.5F,
			description:'Every harry potter fan\'s dream item. \nRepresent HP to the max while keeping your drink cold!!!',
			seller:c1,
			expired: false)
		l1.save(flush:true)
		
		def l2 = new Listing(
			name:"Harry and the hendersons Tshirt",
			endDate:(new Date()+2),
			startingPrice:20.5F,
			description:'Every harry and the hendersons fan\'s dream item. \nRepresent H&H to the max while keeping your drink cold!!!',
			seller:c2,
			expired: false)
		l2.save(flush:true)
		
		def l3 = new Listing(
			name:"World of warcaft account...",
			endDate:(new Date()+1),
			startingPrice:20.5F,
			description:'Max level!!!',
			seller:c3,
			expired: false)
		l3.save(flush:true)
		
		def l4 = new Listing(
			name:"Steve Jobs authentic turtle neck!",
			endDate:(new Date()+4),
			startingPrice:10000.0F,
			description:'Live everyday like the innovator himself.',
			seller:c1,
			expired: false)
		l4.save(flush:true)
		
		def l5 = new Listing(
			name:"Bill Gates fanny pack!",
			endDate:(new Date()+10),
			startingPrice:10000.0F,
			description:'Live everyday like the innovator\'s minion.',
			seller:c1,
			expired: false)
		l5.save(flush:true)
		
		def l6 = new Listing(
			name:"Dexter kill suit!",
			endDate:(new Date()+16),
			startingPrice:10000.0F,
			description:'Live everyday like the dark passenger.',
			seller:c1,
			expired: false)
		l6.save(flush:true)

		l6.addToBids(new Bid(amount:10005.0F, bidder:c1))
		l6.save()
	}

	def destroy = {
	}
}
